//
//  ViewController.swift
//  iOS-RxSwift-Tutorials
//
//  Created by changqing.chen on 09/17/2020.
//  Copyright (c) 2020 changqing.chen. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    @IBOutlet weak var tableView: UITableView!
    
    let array: [String] = [
        "1.Observable - 可监听序列"
        ,"2.Observable - 订阅、事件监听、订阅销毁"
        ,"3.Observer - 观察者"
        ,"4.Observer - 自定义可绑定属性"
        ,"5.Subjects、Variables"
        ,"6.变换操作符：buffer、map、flatMap、scan等"
        ,"7.过滤操作符：filter、take、skip等"
        ,"8.条件和布尔操作符：amb、takeWhile、skipWhile等"
        ,"9.结合操作符：startWith、merge、zip等"
        ,"10.算数&聚合操作符：toArray、reduce、concat"
        ,"11.连接操作符：connect、publish、replay、multicast"
        ,"12.其他操作符：delay、materialize、timeout等"
        ,"13.错误处理操作"
        ,"14.调试操作"
        ,"15.特征序列1：Single、Completable、Maybe"
        ,"16.特征序列2：Driver"
        ,"17.特征序列3：ControlProperty、ControlEvent"
        ,"18.调度器、subscribeOn、observeOn"
        ,"19.UI控件扩展1：UILabel"
        ,"20.UI控件扩展2：UITextField、UITextView"
        ,"21.UI控件扩展3：UIButton、UIBarButtonItem"
        ,"22.UI控件扩展4：UISwitch、UISegmentedControl"
        ,"23.UI控件扩展5：UIActivityIndicatorView、UIApplication"
        ,"24.UI控件扩展6：UISlider、UIStepper"
        ,"25.双向绑定：<->"
        ,"26.UI控件扩展7：UIGestureRecognizer"
        ,"27.UI控件扩展8：UIDatePicker"
        ,"28.UITableView的使用1：基本用法"
        ,"29.UITableView的使用2：RxDataSources"
        ,"30.UITableView的使用3：刷新表格数据"
        ,"31.UITableView的使用5：可编辑表格"
        ,"32.UITableView的使用6：不同类型的单元格混用"
        ,"33.UITableView的使用7：样式修改"
        ,"34.UICollectionView的使用1：基本用法"
        ,"35.UICollectionView的使用2：RxDataSources"
        ,"36.UICollectionView的使用3：刷新集合数据"
        ,"37.UICollectionView的使用4：样式修改"
        ,"38.UIPickerView的使用"
        ,"39.URLSession的使用1：请求数据"
        ,"40.URLSession的使用2：结果处理、模型转换"
        ,"41.结合RxAlamofire使用1：数据请求"
        ,"42.结合RxAlamofire使用2：结果处理、模型转换"
        ,"43.结合RxAlamofire使用3：文件上传"
        ,"44.结合RxAlamofire使用4：文件下载"
        ,"45.结合Moya使用1：数据请求"
        ,"46.结合Moya使用2：结果处理、模型转换"
        ,"47.MVVM架构演示2：使用Observable样例"
        ,"48.MVVM架构演示3：使用Driver样例"
        ,"49.一个用户注册样例1：基本功能实现"
        ,"50.结合MJRefresh使用1：下拉刷新"
        ,"51.DelegateProxy样例1：获取地理定位信息"
        ,"52.DelegateProxy样例2：图片选择功能"
        ,"53.DelegateProxy样例3：应用生命周期的状态变化"
        ,"54.sendMessage和methodInvoked的区别"
        ,"55.订阅UITableViewCell里的按钮点击事件"
        ,"56.通知NotificationCenter的使用"
        ,"57.键值观察KVO的使用"
        ,"58.表格图片加载优化"
        ,"59.检测当前值与初始值是否相同：isEqualOriginValue"
        ,"60.重复执行某个操作序列：repeatWhen"
        ,"61.监听滚动条滚动到底部的行为：reachedBottom"
        ,"62.RxFeedback架构1：安装配置、基本用法"
        ,"63.RxFeedback架构2：一个用户注册样例"
        ,"64.RxFeedback架构3：GitHub资源搜索样例"
        ,"65.ReactorKit架构1：安装配置、基本用法"
        ,"66.ReactorKit架构2：一个用户注册样例"
        ,"67.ReactorKit架构3：GitHub资源搜索样例"
    ]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

extension ViewController: UITableViewDelegate {
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        
        switch indexPath.row {
        case 0:
            let vc = ObservableCreateViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 1:
            let vc = ObservableSubscribeViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 2:
            let vc = ObserverCreateViewController(nibName: "ObserverCreateViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 3:
            let vc = ObserverCustomBindViewController(nibName: "ObserverCustomBindViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 4:
            let vc = SubjectsVariablesViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 5:
            let vc = TransformingObservablesViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 6:
            let vc = FilteringObservablesViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 7:
            let vc = ConditionalandBooleanOperatorsViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 8:
            let vc = CombiningObservablesViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 9:
            let vc = MathematicalandAggregateOperatorsViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 10:
            let vc = ConnectableObservableOperatorsViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 11:
            let vc = ObservableUtilityOperatorsViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 12:
            let vc = ErrorHandlingOperatorsViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 13:
            let vc = DebugViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 14:
            let vc = SpecialObservableViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 15:
            let vc = DriverViewController(nibName: "DriverViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 16:
            let vc = ControlPropertyViewController(nibName: "ControlPropertyViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 17:
            let vc = SchedulersViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 18:
            let vc = UILabelViewController(nibName: "UILabelViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 19:
            let vc = UITextFieldAndTextViewViewController(nibName: "UITextFieldAndTextViewViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 20:
            let vc = ButtonTestViewController(nibName: "ButtonTestViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 21:
            let vc = SwitchSegmentedControlViewController(nibName: "SwitchSegmentedControlViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 22:
            let vc = ActivityIndicatorViewUIApplicationViewController(nibName: "ActivityIndicatorViewUIApplicationViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 23:
            let vc = SliderStepperViewController(nibName: "SliderStepperViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 24:
            let vc = DounbleBindViewController(nibName: "DounbleBindViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 25:
            let vc = GestureRecognizerViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 26:
            let vc = DatePickerViewController(nibName: "DatePickerViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 27:
            let vc = TableView1ViewController(nibName: "TableView1ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 28:
            let vc = RxDataSourcesViewController(nibName: "RxDataSourcesViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 29:
            let vc = TableViewReloadDataViewController(nibName: "TableViewReloadDataViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 30:
            let vc = TableViewEditViewController(nibName: "TableViewEditViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 31:
            let vc = TableViewSomeCellsViewController(nibName: "TableViewSomeCellsViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 32:
            let vc = TableViewStyleModifyViewController(nibName: "TableViewStyleModifyViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 33:
            let vc = CollectionViewBaseUseViewController(nibName: "CollectionViewBaseUseViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 34:
            let vc = RxDataSourcesCollectionViewViewController(nibName: "RxDataSourcesCollectionViewViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 35:
            let vc = CollectionViewReloadDataViewController(nibName: "CollectionViewReloadDataViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 36:
            let vc = CollectionViewStyleModifyViewController(nibName: "CollectionViewStyleModifyViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 37:
            let vc = PickerViewViewController(nibName: "PickerViewViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 38:
            let vc = URLSessionTest1ViewController(nibName: "URLSessionTest1ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 39:
            let vc = URLSessionTestsViewController(nibName: "URLSessionTestsViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 40:
            let vc = RxAlamofireTestViewController(nibName: "RxAlamofireTestViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 41:
            let vc = RxAlamofireTestsViewController(nibName: "RxAlamofireTestsViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 42:
            let vc = RxAlamofireUploadViewController(nibName: "RxAlamofireUploadViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 43:
            let vc = RxAlamofireDownloadViewController(nibName: "RxAlamofireDownloadViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 44:
            let vc = MoyaTest1ViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 45:
            let vc = MoyaTestsViewController(nibName: "MoyaTestsViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 46:
            let vc = MVVMTestViewController(nibName: "MVVMTestViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 47:
            let vc = MVVMDriverViewController(nibName: "MVVMDriverViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 48:
            let vc = RegisterViewController(nibName: "RegisterViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 49:
            let vc = MJRefreshViewController(nibName: "MJRefreshViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 50:
            let vc = RxCLLocationManagerDelegateProxyViewController(nibName: "RxCLLocationManagerDelegateProxyViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 51:
            let vc = RxImagePickerDelegateProxyViewController(nibName: "RxImagePickerDelegateProxyViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 52:
            let vc = RxUIApplicationDelegateProxyViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 53:
            let vc = SendMessageMethodInvokedViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 54:
            let vc = TableViewCellButtonClickViewController(nibName: "TableViewCellButtonClickViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 55:
            let vc = NotificationCenterTestViewController(nibName: "NotificationCenterTestViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 56:
            let vc = KVOTestViewController(nibName: "KVOTestViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 57:
            let vc = TableViewImageViewOptimizationViewController(nibName: "TableViewImageViewOptimizationViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 58:
            let vc = IsEqualOriginValueViewController(nibName: "IsEqualOriginValueViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 59:
            let vc = RepeatWhenViewController()
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 60:
            let vc = ReachedBottomViewController(nibName: "ReachedBottomViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 61:
            let vc = RxFeedbackTest1ViewController(nibName: "RxFeedbackTest1ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 62:
            let vc = RxFeedbackTest2ViewController(nibName: "RxFeedbackTest2ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 63:
            let vc = RxFeedbackTest3ViewController(nibName: "RxFeedbackTest3ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 64:
            let vc = ReactorKitTest1ViewController(nibName: "ReactorKitTest1ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 65:
            let vc = ReactorKitTest2ViewController(nibName: "ReactorKitTest2ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        case 66:
            let vc = ReactorKitTest3ViewController(nibName: "ReactorKitTest3ViewController", bundle: nil)
            self.navigationController?.pushViewController(vc, animated: true)
            break
        default:
            break
        }
    }
}

extension ViewController: UITableViewDataSource {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return array.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        if cell == nil {
            cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
        }
        cell?.textLabel?.text = array[indexPath.row]
        return cell!
    }
}

